import request from '@/config/axios'

// 平台商品 VO
export interface GoodsVO {
  id: number // ID
  mode: string // 模式
}

// 平台商品 API
export const GoodsApi = {
  // 查询平台商品分页
  getGoodsPage: async (params: any) => {
    return await request.get({ url: `/wo/goods/page`, params })
  },

  importNewGoods: async (data?: Array<number>) => {
    return await request.post({ url: `/wo/goods/import`, data })
  },

  // 修改平台商品
  syncGoods: async (data: GoodsVO) => {
    return await request.put({ url: `/wo/goods/sync`, data })
  },

  // 查询平台商品详情
  getGoods: async (id: number) => {
    return await request.get({ url: `/wo/goods/get?id=` + id })
  },

  // 新增平台商品
  createGoods: async (data: GoodsVO) => {
    return await request.post({ url: `/wo/goods/create`, data })
  },

  // 修改平台商品
  updateGoods: async (data: GoodsVO) => {
    return await request.put({ url: `/wo/goods/update`, data })
  },

  // 删除平台商品
  deleteGoods: async (id: number) => {
    return await request.delete({ url: `/wo/goods/delete?id=` + id })
  },

  // 导出平台商品 Excel
  exportGoods: async (params) => {
    return await request.download({ url: `/wo/goods/export-excel`, params })
  },

  // ==================== 子表（产品规格） ====================

  // 获得产品规格列表
  getGoodsSkuListByGoodsId: async (goodsId) => {
    return await request.get({ url: `/wo/goods/goods-sku/list-by-goods-id?goodsId=` + goodsId })
  }
}
